/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: MyMapper
 * Author:   zhouheng
 * Date:     2019/6/9 14:19
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */

package com.zhouh.golden.common.config;

import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author zhouheng
 * @create 2019/6/9
 * @since 1.0.0
 */
public interface MyMapper<T> extends Mapper<T>,MySqlMapper<T>,MyBatchUpdateMapper<T>{
    default int deleteWithVersion(T t){
        int result = delete(t);
        if(result == 0){
            throw new RuntimeException("删除失败!");
        }
        return result;
    }

    default int updateByPrimaryKeyWithVersion(Object t){
        int result = updateByPrimaryKey((T) t);
        if(result == 0){
            throw new RuntimeException("更新失败!");
        }
        return result;
    }
}
